package com.tjl.util;

import lombok.Data;

/**
 * @author TJL
 * @date 2022/4/24
 * 202 token过期
 */
@Data
public class CodeMsg {
    public int code;
    public Object data;
    public String msg;
    public String token;

    public CodeMsg(boolean isOk, String failureMsg) {
        if (isOk){
            this.code = 200;
            this.msg = failureMsg;
        }else {
            this.code = 201;
            this.msg = failureMsg;
        }
    }

    public CodeMsg(int code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    public CodeMsg(Object data, String token) {
        this.data = data;
        this.token = token;
        this.code = 200;
        this.msg = "操作成功";
    }

    public CodeMsg(boolean isOk) {
        if (isOk){
            this.code = 200;
            this.msg = "操作成功";
        }else {
            this.code = 201;
            this.msg = "操作失败";
        }
    }

    public CodeMsg(Object books) {
       this.data = books;
       this.code = 200;
       this.msg = "查询成功";
    }

    public CodeMsg(){

    }
}

